<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <link href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
    <script type="text/javascript">
        function doDelete(cid){
            var flag = confirm("您确定删除购物车吗？")
            if(flag){
                window.location.href="${pageContext.request.contextPath}/user/deleteCart?cid="+cid;
            }
        }
    </script>
</head>
<body>
<h1>路线展示</h1>
<div class="container">
    <div class="row clearfix">
        <div class="col-md-12 column">
            <div class="page-header">
                <h1>购物车列表--显示所有购物车</h1>
            </div>
        </div>
        <div class="row">
            <div class="col-md-4 colum">
                <a class="btn btn-default" href="${pageContext.request.contextPath}/path/toAddPath">新增路线</a>
                <span style="color: red;font-weight: bold">${queryError} </span>
            </div>
            <div class="col-md-4 colum">
                <%-- 查询 --%>
                <form class="form-inline" action="${pageContext.request.contextPath}/path/getPathByName" method="post" style="float: right">
                    <input type="text" id="pathname" name="pathname" class="form-control" placeholder="输入查询的路线名">
                    <input type="submit" value="查询" class="btn btn-default">
                </form>
            </div>
        </div>


    </div>

    <div class="row clearfix">
        <div class="col-md-12 column">
            <table class="table table-hover table-striped">
                <thead>
                <tr>
                    <th>图片</th>
                    <th>路线名</th>
                    <th>价格</th>
                    <th>数量</th>
                </tr>
                </thead>
                <%--书籍从数据库中查询出来，从list中便利出来 ：foreach--%>
                <tbody>
                <c:forEach var="cart" items="${cartList.list}" >
                    <tr>
                        <td>
                            <c:if test="${cart.path.pics != null }">
                                <a href="${pageContext.request.contextPath}/path/showPathInfo?pid=${cart.path.pid}">
                                    <img id="images" width="50px" height="50px" src="${pageContext.request.contextPath}/upload/${cart.path.pics}">
                                </a>
                            </c:if>
                        </td>
                        <td>${cart.path.pathname}</td>
                        <td>${cart.path.price}</td>
                        <td>${cart.num}</td>
                        <td>
                            <a class="btn btn-default" onclick="doDelete('${cart.cid}')">删除</a>
                        </td>
                    </tr>
                </c:forEach>
                </tbody>
            </table>
            <div style="float: right">
                <ul class="pagination pagination-right">
                    <li><a href="${pageContext.request.contextPath}/user/allCart?page=1&size=${PageInfo1.pageSize}" >首页</a></li>
                    <li><a href="${pageContext.request.contextPath}/user/allCart?page=${PageInfo1.pageNum-1}&size=${PageInfo1.pageSize}">上一页</a></li>
                    <c:forEach begin="${PageInfo1.pageNum}" end="${PageInfo1.pageNum+2}" var="pageNum">
                        <li><a href="${pageContext.request.contextPath}/user/allCart?page=${pageNum}&size=${PageInfo1.pageSize}" >${pageNum}</a></li>
                    </c:forEach>
                    <li><a href="${pageContext.request.contextPath}/user/allCart?page=${PageInfo1.pageNum+1}&size=${PageInfo1.pageSize}" >下一页</a></li>
                    <li><a href="${pageContext.request.contextPath}/user/allCart?page=${PageInfo1.pages}&size=${PageInfo1.pageSize}">尾页</a></li>
                </ul>
            </div>


        </div>
    </div>


</div>




</body>
</html>
